﻿<frameworkControls:NavigatePhoneApplicationPage 
    x:Class="mal.WP7.GoogleAnalytics.WebsitePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728"
    xmlns:frameworkControls="clr-namespace:mal.WP7.Framework.Controls;assembly=mal.WP7.Framework"
    xmlns:local="clr-namespace:mal.WP7.GoogleAnalytics"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
     shell:SystemTray.IsVisible="False">

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot">
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <local:HeaderBackground Grid.RowSpan="2" VerticalAlignment="Top" />
        
        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,5,0,00">
            <TextBlock x:Name="ApplicationTitle" Text="{Binding Website.Name}" 
                       Style="{StaticResource PhoneTextNormalStyle}"/>          
        </StackPanel>

        <StackPanel Grid.Row="1" VerticalAlignment="Top" Orientation="Horizontal">
            <ToggleButton Content="{Binding Text.Day, Source={StaticResource Resource}}" IsChecked="{Binding DaySelected, Mode=TwoWay}"/>
            <ToggleButton Content="{Binding Text.Week, Source={StaticResource Resource}}" IsChecked="{Binding WeekSelected, Mode=TwoWay}"/>
            <ToggleButton Content="{Binding Text.Month, Source={StaticResource Resource}}" IsChecked="{Binding MonthSelected, Mode=TwoWay}"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">  
            <Grid.RowDefinitions>
                <RowDefinition  />
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <frameworkControls:BarChart Grid.Row="0" 
                                Visibility="{Binding IsLoading, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=inverse}"
                                YAxisTitle="Visits"
                                Values="{Binding Values, Mode=TwoWay}" >
                <frameworkControls:BarChart.Fill>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,0" Opacity="0.8">
                        <GradientStop Color="Transparent" Offset="0.0" />
                        <GradientStop Color="Transparent" Offset="0.2" />
                        <GradientStop Color="#1BA1E2" Offset="0.2" />
                        <GradientStop Color="#1BA1E2" Offset="0.5" />
                        <GradientStop Color="#1BA1E2" Offset="0.8" />
                        <GradientStop Color="Transparent" Offset="0.8" />
                        <GradientStop Color="Transparent" Offset="0.0" />
                        <!--<GradientStop Color="{StaticResource PhoneAccentColor}" Offset="0.0" />-->
                        <!--  <GradientStop Color="Transparent" Offset="0.9" />-->
                    </LinearGradientBrush>

                </frameworkControls:BarChart.Fill>

                <frameworkControls:BarChart.HighlightFill>
                    <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
                </frameworkControls:BarChart.HighlightFill>
            </frameworkControls:BarChart>

            <Grid Grid.Row="1" Margin="0,5,0,5">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <TextBlock Text="Visits : " Grid.Row="0" Grid.Column="0" />
                <TextBlock Text="{Binding Visits}" Grid.Row="0" Grid.Column="1" />

                <TextBlock Text="Unique Visitors : " Grid.Row="1" Grid.Column="0" />
                <TextBlock Text="{Binding Visitors}" Grid.Row="1" Grid.Column="1" />

                <TextBlock Text="Pageviews : " Grid.Row="2" Grid.Column="0" />
                <TextBlock Text="{Binding PageViews}" Grid.Row="2" Grid.Column="1" />

                <TextBlock Text="Pages/Visit : " Grid.Row="3" Grid.Column="0" />
                <TextBlock Text="{Binding PagesViewPerVisit, StringFormat=\{0:F2\}}" Grid.Row="3" Grid.Column="1" />

               </Grid>   

            <StackPanel Visibility="{Binding IsLoading, Converter={StaticResource BoolToVisibilityConverter}}"
                                 Grid.RowSpan="2"
                                 VerticalAlignment="Center">
                <ProgressBar IsIndeterminate="True"   />
                <TextBlock   HorizontalAlignment="Center"
                                    Style="{StaticResource PhoneTextSmallStyle}"
                                Text="{Binding Text.Loading , Source={StaticResource Resource}}" />
            </StackPanel>
        </Grid>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="HomeButton" IconUri="/Images/appbar.list.rest.png"                                             
                                            Text="sites web" Click="HomeButton_Click" />

            
            <shell:ApplicationBarIconButton x:Name="PinButton" IconUri="/Images/appbar.pin.rest.png"                                             
                                            Text="pin" Click="PinButton_Click" />
            <!--<shell:ApplicationBarIconButton IconUri="/Images/appbar.close.rest.png" 
                                            Text="fermer" Click="OnCloseClick"/>-->
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</frameworkControls:NavigatePhoneApplicationPage >